package sort;

import java.util.Arrays;

/**
 * @author songZiHao
 * @version 1.0.0
 * @ClassName BubbleSort.java
 * @Description TODO
 * @createTime 2020年09月21日 19:59:00
 */
public class BubbleSort {
	public static void main(String[] args) {
		int[] arr = {1, 12, 3, 13, 14, 2, 44, 4, 56, 7};
		sortArray(arr);
		System.out.println(Arrays.toString(arr));
	}

	private static void sortArray2(int[] arr) {
		for (int i = 0; i < arr.length-1; i++) {
			for (int j = 0; j < arr.length-1; j++) {
				if (arr[j]>arr[j+1]){
					int temp=arr[j+1];
					arr[j+1]=arr[j];
					arr[j]=temp;
				}
			}
		}
	}

	private static void sortArray(int[] arr) {
		for (int i = 0; i < arr.length-1; i++) {
			for (int j = 0; j < arr.length-1; j++) {
				if (arr[j]>arr[j+1]){
					int temp=arr[j+1];
					arr[j+1]=arr[j];
					arr[j]=temp;
				}
			}
		}
	}
}
